<template>
  <div>
    <van-row>
      <van-col span="24">
        <div class="article-title">{{ article.title }}</div>
      </van-col>
      <van-col span="24">
        <div class="article-author">作者： {{ article.author }}</div>
      </van-col>
    </van-row>
    <van-row>
      <van-col span="24">
        <wxParse :content="article.content"></wxParse>
      </van-col>
    </van-row>

  </div>
</template>

<script>
import utils from "@/utils/index.js";
import wxParse from "mpvue-wxparse";
import store from "@/utils/store.js";

export default {
  components: {
    wxParse
  },
  data() {
    return {
      article: {},
    };
  },

  computed: {
  },
  methods: {

    getArticle(id) {
      var that = this;
      that.$API.post("banner/getArticleById?id=" + id).then(res => {

        let article = {};
        article.id = res.data.id;
        article.title = res.data.title;
        article.author = res.data.author;
        let host = utils.host;
        article.content = res.data.content.replace(/..\/boss-api\//g, host);
        article.imgUrl = utils.fileMgrUrl + res.data.img;

        that.article = article;
      });
    },
    toHome() {
      const url = "/pages/index/index";
      wx.switchTab({ url });
    },

  },
  onShareAppMessage() {
    return {
      title: this.article.title,
      page: 'pages/article/index?id=' + this.article.id
    }
  },
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: "活动详情"
    })
    let id = options.id;
    this.atricle = {}

    this.getArticle(id);
    console.log(JSON.stringify(this.atricle))
  }
};
</script>

<style lang="wxss">
.img {
  display: flex;
}

.article {
  padding: 10px;
}

.goods-detail {
  width: 100%;
  padding: 15px;
  font-size: 14px;
}

.article-title {
  padding: 15px;
  font-weight:bold;
  font-size: 18px;
}

.article-author {
  padding-left: 15px;
  color: #999;
  font-size: 16px;
}

</style>

